﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using blackhouse.BlackApart.Web;
using blackhouse.BlackApart.Web.Navigation;
using blackhouse.mojoPortalExtend;
using mojoPortal.Business;

namespace blackhouse.Aparts.Web.Navigation {
    public class CmsUrlReservationPageVisitor : UrlVisitor, IReservationPageVisitor {

        public void Apply(ReservationPage page) {
            PageProvider pageProv = new mojoPortalExtend.PageProvider();
            FriendlyUrl fu = pageProv.FindCmsUrlByFunctionality(page.Type.ToString());
            if (fu != null && fu.FoundFriendlyUrl) {
                this.Url = UrlUtils.LocalizeUrl(fu.Url);
                switch (page.Type) {
                    case ReservationSubpageType.AdditionalServices:
                    case ReservationSubpageType.Payment:
                    case ReservationSubpageType.Contact:
                    case ReservationSubpageType.EndReservation:
                    case ReservationSubpageType.Status:
                    case ReservationSubpageType.Confirm:
                    case ReservationSubpageType.PayReservation:
                        this.Url = this.Url + "?reservation=" + page.Reservation.Guid;
                        break;
                    case ReservationSubpageType.Information:
                        this.Url = this.Url + "?search=" + page.State + "&apartment=" + page.ApartmentTypeId;
                        break;
                    default:
                        break;
                }
            }
        }

    }
}